package io.renren.modules.emp.service.impl;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.modules.emp.entity.EmployeeLocationEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.emp.dao.EmployeeDao;
import io.renren.modules.emp.entity.EmployeeEntity;
import io.renren.modules.emp.service.EmployeeService;

@Service("employeeService")
public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, EmployeeEntity> implements EmployeeService {
    @Autowired
    EmployeeDao employeeDao;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String eid =(String) params.get("key");//模糊查询
        boolean blank = StringUtils.isBlank(eid);
        QueryWrapper<EmployeeEntity> queryWrapper;
        if(blank){
            queryWrapper = new QueryWrapper<EmployeeEntity>();
        }else {
            queryWrapper = new QueryWrapper<EmployeeEntity>().like("eid",eid);
        }
        IPage<EmployeeEntity> page = this.page(
                new Query<EmployeeEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }
    @Override
    public void selectByEmployeeid(String eid, Page<EmployeeEntity> page) {
        employeeDao.selectByEmployeeid(eid,page);
    }

    @Override
    public List listNum() {
        return employeeDao.listNum();
    }

    @Override
    public void getLocation(String eid, Page<EmployeeLocationEntity> page) {
         employeeDao.getLocation(eid,page);
    }


//    @Override
//    public List<EmployeeLocationEntity> getLocation(String eid) {
//        System.out.println(employeeDao.getLocation(eid));
//        return employeeDao.getLocation(eid);
//    }


}